/**
 * Copyright (C) 2013 Oleg Anastassov <oleg.anastassov@gmail.com>
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kz.kstu.loc.desktop;

import java.io.InputStream;
import java.util.Properties;

/**
 * Date: 17.01.2013
 * Time: 00:19
 *
 * @author Oleg Anastassov
 */
public final class AppConfig {

    private static final String CONFIG_FILE = "/app.xml";

    private static final String APP_NAME = "app.name";
    private static final String APP_VERSION = "app.version";
    private static final String APP_REVISION = "app.revision";
    private static final String APP_BUILD_DATE = "app.buildDate";
    private static final String APP_AUTHOR = "app.author";
    private static final String APP_EMAIL = "app.email";

    private static AppConfig instance;
    private static Properties properties;

    private AppConfig() {
        properties = new Properties();
        try {
            InputStream is = AppConfig.class.getResourceAsStream(CONFIG_FILE);
            properties.loadFromXML(is);
        } catch (Exception ignored) {
        }
    }

    public static AppConfig getInstance() {
        if (instance == null) {
            instance = new AppConfig();
        }
        return instance;
    }

    public String getAppName() {
        return properties.getProperty(APP_NAME, "<default name>");
    }

    public String getAppVersion() {
        return properties.getProperty(APP_VERSION, "<default version>");
    }

    public String getAppRevision() {
        return properties.getProperty(APP_REVISION, "<default revision>");
    }

    public String getAppBuildDate() {
        return properties.getProperty(APP_BUILD_DATE, "<default build date>");
    }

    public String getAppAuthor() {
        return properties.getProperty(APP_AUTHOR, "<default author>");
    }

    public String getAppEmail() {
        return properties.getProperty(APP_EMAIL, "<default email>");
    }

}
